import { request } from "@/utils/http";
import { Key } from "react";
import type {
  addHospitalSetParamsType,
  getHospitalSetListItemType,
  getHospitalSetListReqReturnType,
  hospitalSetSearchParamsType,
  updateHospitalSetParamsType,
} from "./model/hospitalSetTypes";

export const getHospitalSetListRequest = (
  page: number,
  limit: number,
  search?: hospitalSetSearchParamsType
) => {
  return request.get<any, getHospitalSetListReqReturnType>(
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    {
      params: {
        ...search,
      },
    }
  );
};

export const deleteHospitalSetRequest = (id: number) => {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`);
};

export const batchRemoveHospitalSetRequest = (batchIds: Key[]) => {
  return request.delete<any, null>("/admin/hosp/hospitalSet/batchRemove", {
    data: batchIds,
  });
};

export const addHospitalSetRequest = (data: addHospitalSetParamsType) => {
  return request.post<any, null>("/admin/hosp/hospitalSet/save", data);
};

export const getHosSetFormIdRequest = (id: number) => {
  return request.get<any, getHospitalSetListItemType>(
    `/admin/hosp/hospitalSet/get/${id}`
  );
};

export const updateHospitalRequest = (data: updateHospitalSetParamsType) => {
  return request.put<any, null>("/admin/hosp/hospitalSet/update", data);
};
